package com.enzoism.springboot.dive.scene2;

import com.enzoism.springboot.dive.common.AppConstants;
import com.enzoism.springboot.dive.common.CompareSortUtil;

import java.util.*;

public class Scene2Test {
    /**
     * 场景二：多字段排序（固定使用前端传递的字段顺序进行排序）
     * Map传递格式：sortMap:{"clkNum":"asc","usrId":"desc","usrNum":"asc"}
     */
    public static void main(String[] args) {
        List<Scene2Model> Scene2Models = Scene2Test.initDataList();

        Map<String, String> sortMap = new HashMap<>();
        sortMap.put(AppConstants.ORDER_USR_NUM, AppConstants.ORDER_TYPE_DESC);
        sortMap.put(AppConstants.ORDER_CLK_NUM, AppConstants.ORDER_TYPE_ASC);
        sortMap.put(AppConstants.ORDER_USR_ID, AppConstants.ORDER_TYPE_ASC);
        Scene2Model.setSortMap(ThreadLocal.withInitial(() -> sortMap));
        Collections.sort(Scene2Models);
        Scene2Model.unload();

        CompareSortUtil.printDataList(Scene2Models);
    }


    public static List<Scene2Model> initDataList() {
        List<Scene2Model> dataList = new ArrayList<>();
        Scene2Model Scene2Model1 = new Scene2Model("001", 010, 010);
        Scene2Model Scene2Model2 = new Scene2Model("001", 010, 001);
        Scene2Model Scene2Model3 = new Scene2Model("001", 101, 300);
        Scene2Model Scene2Model4 = new Scene2Model("002", 31, 178);
        Scene2Model Scene2Model5 = new Scene2Model("003", 51, 881);
        Scene2Model Scene2Model6 = new Scene2Model("004", 61, 1);
        Scene2Model Scene2Model7 = new Scene2Model("009", 178, 10);
        Scene2Model Scene2Model8 = new Scene2Model("005", 13, 129);
        Scene2Model Scene2Model9 = new Scene2Model("006", 100, 150);
        dataList.add(Scene2Model1);
        dataList.add(Scene2Model2);
        dataList.add(Scene2Model3);
        dataList.add(Scene2Model4);
        dataList.add(Scene2Model5);
        dataList.add(Scene2Model6);
        dataList.add(Scene2Model7);
        dataList.add(Scene2Model8);
        dataList.add(Scene2Model9);
        return dataList;
    }
}
